<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../../header.jsp"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body style="align: center;">
	<div style="margin-top: 10px; margin-left: 30px;">
		<div style="margin:20px 0px 35px 80px">
					<label for="jobcode">员工角色:</label> 
					<select type="text" style="width: 200px; height: 28px;" class="ui-input" 
					name="rolename" id="cotegoryType">
						<s:forEach items="${sessionScope.roleList}" var="role">
							<option value="${role.rolename}">${role.rolename }</option>
						</s:forEach>
					</select>
		</div>
	</div>

	<script type="text/javascript">
		var api=frameElement.api;
		var operate=api.data.operate;
		var rowid=api.data.rowid;
		var rowdata=api.data.rowdata;
		var CallBack=api.data.callback;
		var rolecode=rowdata["role.rolecode"];
		var roleid=rowdata["role.id"];
		$(function(){
			initPopBtns();
			if(operate=="edit"){
				$("#cotegoryType").val(rowdata.type);
			}
		})
		//初始化按钮
		function initPopBtns() {
			var btnname = "add" == operate ? ["保存", "关闭"] : ["确定", "取消"];
			api.button({
				id: "confirm",
				name: btnname[0],
				focus: true,
				callback: function(e) {
					var rolename=$("#cotegoryType option:selected").val();
					if(operate=="edit"){
						$.ajax({
							url : '/editUserRole',
							type : 'POST',
							dataType : "json",
							data: {
								"id";rowid,
								"rowdata":rowdata,
								"rolecode":rolecode,	
								"rolename":rolename
							},
							async : false,
							success : function(data) {
								if(data.status==200){
									parent.Public.tips({
										content: "修改员工角色成功"
									})
									CallBack();
								}else{
									parent.Public.tips({
										type:1,
										content: "修改员工角色失败:"+data.msg
									})
								}	
							}
						});
					}
				}
			}, {
				id: "cancel",
				name: btnname[1]
			})
		}
		
</script>
</body>
</html>